

import type { Enterprise, Datum,  GetParkEnterpriseParams, GetParkRentBuildingData,  PostParkAddEnterpriseParams,  PostParkEnterpriseParams, PostParkEnterpriseRentParams, PutParkEnterpriseParams, Rent, GetParkEnterpriseDetailData } from "@/types/enterprise";
import service, { request } from "./reuqest";



// 园区管理-企业列表
export const GetParkEnterpriseParamsAPI = (params:GetParkEnterpriseParams) =>{
  return request<Enterprise>('/park/enterprise','GET',params)
}

// 添加企业
export const PostParkEnterpriseAPI = (params:PostParkEnterpriseParams) =>{
  return request('/park/enterprise','POST',params)
}

// 查询企业所属行业列表

export const GetParkIndustryAPI = () =>{
  return request<Datum[]>('/park/industry','GET')
}

//添加企业

export const PostParkAddEnterpriseAPI = (params:PostParkAddEnterpriseParams) =>{
  return request('/park/enterprise','POST',params)
}

// 查看企业
export const GetParkAddEnterpriseParamsAPI = (id:string) =>{
  return request<PostParkAddEnterpriseParams>(`/park/enterprise/${id}`,'GET')
}

// 编辑企业
export const PutParkEnterpriseParamsAPI = (params:PutParkEnterpriseParams) =>{
  return request('/park/enterprise','PUT',params)
}

// 删除企业
export const DeleteParkEnterprise = (id:string) =>{
  return request(`/park/enterprise/${id}`,'DELETE')
}

// 园区管理-添加/续租企业的租赁合同
 export const  PostParkEnterpriseRentAPI = (params:PostParkEnterpriseRentParams)=>{
  return request('/park/enterprise/rent','POST',params)
 }

//  园区管理-查询可租赁楼宇
export const GetParkRentBuildingAPI = () =>{
  return request<GetParkRentBuildingData[]>('/park/rent/building','GET')
}

// 园区管理-企业租赁信息列表-展开查看

export const GetParkEnterpriseRentAPI = (id:number) =>{
  return request<Rent[]>(`/park/enterprise/rent/${id}`,'GET')
}
  // 园区管理 -退租
  export const PutParkEnterpriseRentAPI = (id:number) =>{
    return request(`/park/enterprise/rent/${id}`,'PUT')
  }

  // 园区管理 - 删除租赁合同  
  export const DeleteParkEnterpriseRentAPI = (rentid:number) =>{
    return request(`/park/enterprise/rent/${rentid}`,'DELETE')
  }

  // 园区管理-查看企业
  export const GetParkEnterpriseDetailAPI = (id:number) =>{ 
    return request<GetParkEnterpriseDetailData>(`/park/enterprise/${id}`,'GET')
  }

  // **
  // * 下载合同文件
  // * @param id 合同 id
  // * @returns 
  // */
 export const downloadContract = (id: number) => {
   // 第二个范型参数为 Blob
   return service<null, Blob>({
     method: 'GET',
     url: `/download/${id}`,
     responseType: 'blob' // 把二进制数据流转换成 blob 对象，用于下载
   })
 }